<template>
	<view>
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#D23030"></u-tabs>
		<view class="pad15 bg-f">
			<u-form :model="form" ref="uForm" label-position="top" v-show="this.current==0">
				<u-form-item label="公司名称">
					<u-input v-model="form.name" placeholder="请输入公司名称" disabled/>
				</u-form-item>
				<u-form-item label="法人姓名">
					<u-input v-model="form.contacts" placeholder="请输入法人姓名" disabled/>
				</u-form-item>
				<u-form-item label="法人联系方式">
					<u-input v-model="form.mobile" placeholder="请输入法人联系方式" disabled/>
				</u-form-item>
				<u-form-item label="上传身份证正反面" :border-bottom="false">
					<view class="flex row-between">
						<view class="text-center" >
							<image :src="form.idcard_front" class="h226 w330 mr30"></image>
							<text>正面</text>
						</view>
						<view class="text-center" >
							<image :src="form.idcard_back" class="h226 w330 mr30"></image>
							<text>反面</text>
						</view>
					</view>
				</u-form-item>
			</u-form>
			<u-form :model="form2" ref="uForm" label-position="top" v-show="this.current==1">
				<u-form-item label="店铺简介">
					<u-input v-model="form2.content" placeholder="" type="textarea"/>
				</u-form-item>
				<u-form-item label="店铺logo" :border-bottom="false">
					<image :src="logoimg" class="h226 w330 mr30" v-if="showlogo"></image>
				<!-- 	<u-upload ref="uUpload2" name='img' :action="action" :auto-upload="true"  max-count='1' @on-success='logoOk'>
					</u-upload> -->
				</u-form-item>
				<u-form-item label="店铺轮播图" :border-bottom="false">
					<block v-for="(item,i) in form.images" :key='i'>
						<image :src="item" class="w200 h200" @click="btnPic"></image>
					</block>
					
					
				<!-- 	<u-upload ref="uUpload" name='img' :action="action" :auto-upload="true"  max-count='5' @on-success='picOk' :file-list='fileList'>
					</u-upload> -->
					<!-- <u-button @click="submit">提交</u-button> -->
				</u-form-item>
			</u-form>
			<!-- 底部的确认按钮 -->
			<view class="footerbtn h88" @click="submit">
				立即修改
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:'shopAdmin',
		onLoad() {
			this.form = uni.getStorageSync('shopDetail')
			if(uni.getStorageSync('shopDetail').logo) {
				this.showlogo=true
				this.logoimg=uni.getStorageSync('shopDetail').logo
			}
			if(uni.getStorageSync('shopDetail').images.length>0) {
				uni.getStorageSync('shopDetail').images.forEach(item=>{
					let obj={}
					if(item) {
						obj.url=item
						this.fileList.push(obj)
					}
				})
			}
		},
		data() {
			return {
				list: [{
					name: '基本信息'
				}, {
					name: '店铺信息'
				}],
				current: 1,
				form: {
					//公司名称
					name: '',
					//法人名称
					contacts: '',
					//手机号
					mobile: '',
					//身份证正面
					idcard_front: '',
					//	身份证反面
					idcard_back: '',
				},
				form2: {
					logo: '',
					images: [],
					content: ''
				},
				action: this.$baseUrl + '/index.php/system/Basic/postUploadOne',
				//
				logoimg:'',
				showlogo:false,
				fileList:[]
			};
		},
		methods: {
			change(index) {
				this.current = index;
			},
			// logoOk(data) {
			// 	console.log(data)
			// 	if(data.code==1) {
			// 		this.showlogo=false
			// 	} 
			// },
			// picOk(data) {
			// 	console.log(data)
			// 	if(data.code==1) {
			// 		this.showShopPic=false
			// 	} 
			// },
			submit() {
				uni.showModal({
				    title: '提示',
				    content: '修改店铺信息请联系管理员',
				    success: function (res) {
				        if (res.confirm) {
				            console.log('用户点击确定');
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
				// let filesimage = [];
				// // 通过filter，筛选出上传进度为100的文件(因为某些上传失败的文件，进度值不为100，这个是可选的操作)
				// filesimage = this.$refs.uUpload.lists.filter(val => {
				// 	return val.progress == 100;
				// })
				// // 如果您不需要进行太多的处理，直接如下即可
				// // files = this.$refs.uUpload.lists;
				// console.log(filesimage)
				// this.form2.images=filesimage.map(item=>{
				// 	return item.response.id
				// })
				// this.form2.images=this.form2.images.join() 
				// console.log(222,this.form2.images)
				// let fileslogo = [];
				// // 通过filter，筛选出上传进度为100的文件(因为某些上传失败的文件，进度值不为100，这个是可选的操作)
				// fileslogo = this.$refs.uUpload2.lists.filter(val => {
				// 	return val.progress == 100;
				// })
				// // 如果您不需要进行太多的处理，直接如下即可
				// // files = this.$refs.uUpload.lists;
				// console.log(fileslogo)
				// fileslogo.forEach(item=>{
				// 	 this.form2.logo=item.response.id
				// })
				// this.form2.logo=this.form2.logo
				// console.log(333,this.form2.logo)
				// console.log('444',this.form2)
				// // return
				// this.$api.editShop(this.form2).then(res=>{
				// 	console.log(res)
				// 	this.$msg(res.msg)
				// 	this.form2={}
				// 	return
				// 	setTimeout(()=>{
				// 		uni.navigateBack({
							
				// 		})
				// 	},800)
				// })
			}
		}
	}
</script>

<style lang="scss">
	.footerbtn {
		position: fixed;
		width: 90%;
		left: 50%;
		bottom: 60rpx;
		transform: translateX(-50%);
		background: #D23030;
		box-shadow: 0px 2rpx 10rpx 0px rgba(210, 48, 48, 1);
		border-radius: 44rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 88rpx;
	}
</style>
